﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityModel;
using Common;

namespace Services
{
    public class WebConfigService
    {
        #region***属性数据***
        ShopDbEntities bdContext = DbContextHelper.GetCurrentDbContext();
        #endregion

        #region 获取实体
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <returns></returns>
        public WebConfig GetModel()
        {
            return bdContext.WebConfigs.FirstOrDefault(w => w.Id == 1);
        }
        #endregion

        #region 更新配置
        /// <summary>
        /// 更新配置
        /// </summary>
        /// <param name="web"></param>
        public void UpdateConfig(WebConfig web)
        {
            WebConfig config = bdContext.WebConfigs.FirstOrDefault(w => w.Id == web.Id);
            config.KeyWord = web.KeyWord;
            config.Icp = web.Icp;
            config.Email = web.Email;
            config.Description = web.Description;
            config.Address = web.Address;
            config.Name = web.Name;
            config.StatisticsTool = web.StatisticsTool;
            config.Tel = web.Tel;
            bdContext.SaveChanges();
        }
        #endregion
    }
}
